/**
 * Created by Arnald on 2017/5/11.
 */
let msg = require('../util/msg.js');
let game = require('./game.js');
let room = require('./room.js');

module.exports = action;

function action(obj, cid) {
    if (!obj.userId) {
        msg.send(cid, obj.uuid, 'error', {'api': obj.action, 'code': 10018});
        return false;
    }
    let data = obj.data;
    switch (obj.action) {
        case 'gameJoin':
            game.join(obj, cid, data);
            break;
        case 'gameMsg':
            game.msg(obj, cid, data);
            break;
        case 'gameReady':
            game.ready(obj, cid, data);
            break;
        case 'gameAskChip':
            game.askChip(obj, cid, data);
            break;
        case 'gameAskDZ':
            game.askDz(obj, cid, data);
            break;
        case 'gameRobDZ':
            game.robDZ(obj, cid, data);
            break;
        case 'gameDouble':
            game.double(obj, cid, data);
            break;
        case 'gameShowCard':
            game.showCard(obj, cid, data);
            break;
        case 'gameAuto':
            game.auto(obj, cid, data);
            break;
        case 'gamePlay':
            game.play(obj, cid, data);
            break;
        case 'gameExit':
            game.exit(obj, cid, data);
            break;
        case 'gamePraise':
            game.praise(obj, cid, data);
            break;
        case 'createRoom':
            msg.send(cid, obj.uuid, 'createRoom', room.create(data));
            break;
        case 'happyRoom':
            msg.send(cid, obj.uuid, 'happyRoom', room.happy(data));
            break;
        case 'customRoom':
            msg.send(cid, obj.uuid, 'customRoom', room.custom(data));
            break;
        case 'followRoom':
            msg.send(cid, obj.uuid, 'followRoom', room.follow(data));
            break;
        case 'arenaRoom':
            msg.send(cid, obj.uuid, 'arenaRoom', room.arena(data));
            break;
        //case 'rpcInArena':
        //    game.rpcInArena(obj, cid, data);
        //    break;
    }
}